//
//  DeliverFeedbackVC.m
//  u76ho
//
//  Created by m-air-01 on 16/1/19.
//  Copyright © 2016年 LV. All rights reserved.
//

#import "DeliverFeedbackVC.h"
#import "RecommendCompanyCell.h"
#import "DeliverSuccessViewController.h"
@interface DeliverFeedbackVC ()
<UITableViewDataSource,UITableViewDelegate>
{
    UITableView * _tableView;
    NSMutableArray * dataSouce;
}
@end

@implementation DeliverFeedbackVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self main];
    
    self.navigationItem.title  = @"投递反馈";
   // [self addBackItem];
   // [self addNavgationBar];
    // Do any additional setup after loading the view.
}
-(void)main
{
    dataSouce = [[NSMutableArray alloc]init];
    self.view.backgroundColor = UIColorFromRGB(0xf1f3f2);
    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 50, SCREEN_WIDTH, SCREEN_HEIGHT) style:UITableViewStyleGrouped];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [_tableView registerNib:[UINib nibWithNibName:@"RecommendCompanyCell" bundle:nil] forCellReuseIdentifier:@"RecommendCompanyCell"];
    [self.view addSubview:_tableView];
    self.automaticallyAdjustsScrollViewInsets = NO;
    [self requestData];
}
-(void)requestData
{
    [U76HONet feedBackListWithAction:@"" code:[Singleton share].code andDataBlock:^(NSArray *arr) {
        NSLog(@"投递反馈列表接口获取数据成功了");
        if (arr.count == 0) {
            [self nosearch];
        }
        else
        {
            if (dataSouce.count != 0) {
                [dataSouce removeAllObjects];
            }
            [dataSouce addObjectsFromArray:arr];
            [_tableView reloadData];
        }
    }];
}
-(void)nosearch
{
    UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT-64)];
    view.backgroundColor = UIColorFromRGB(0xf1f3f2);
    view.tag = 504;
    
    UIImageView * imgV = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2-98/2,SIZETO6H(120), 98, 100)];
    imgV.image = [UIImage imageNamed:@"苦脸"];
    [view addSubview:imgV];
    
    UILabel * tipLab = [[UILabel alloc]initWithFrame:CGRectMake(0, imgV.bottom+SIZETO6H(20), SCREEN_WIDTH, 20)];
    tipLab.text = @"暂时没有符合条件的内容";
    tipLab.textAlignment = NSTextAlignmentCenter;
    tipLab.font = [UIFont systemFontOfSize:14];
    tipLab.textColor = UIColorFromRGB(0x333944);
    [view addSubview:tipLab];
    [self.view addSubview:view];
}

#pragma mark - _tableViewDelegate
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return dataSouce.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    RecommendCompanyCell * cell = [tableView dequeueReusableCellWithIdentifier:@"RecommendCompanyCell"];
    cell.isHiddenZP = @"YES";
    if (dataSouce.count!=0) {
        cell.positionlistmodel = dataSouce[indexPath.row];
    }
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//    if (indexPath.row == 0) {
//        DeliverFailedViewController * failedVC = [[DeliverFailedViewController alloc]init];
//        [self.navigationController pushViewController:failedVC animated:YES];
//    }
//    else
//    {
//        DeliverSuccessViewController * successVC = [[DeliverSuccessViewController alloc]init];
//        [self.navigationController pushViewController:successVC animated:YES];
//    }
    DeliverSuccessViewController * successVC = [[DeliverSuccessViewController alloc]init];
    PositionDeliverListModel * model = dataSouce[indexPath.row];
    successVC.idm = model.ids;
    [self.navigationController pushViewController:successVC animated:YES];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 75;
}
#pragma  mark - 返回按钮图标
-(void)addBackItem{
    UIButton * backItem = [UIButton buttonWithType:UIButtonTypeCustom];
    backItem.frame = CGRectMake(0, 0, 9, 17);
    [backItem setImage:[UIImage imageNamed:@"返回图标"] forState:UIControlStateNormal];
    [backItem addTarget:self action:@selector(backItem:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:backItem];
}
-(void)backItem:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
